import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { NoticeBo } from '@/api/business/notice/types'

enum Api {
  list = '/notice/list',
  delete = '/notice/delete',
  publish = '/notice/publish',
  add = '/notice/add',
  edit = '/notice/edit',
}

// 查询公告列表
export function noticeList(data: any): AxiosPromise<any> {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const noticeSave = (data: NoticeBo) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 删除
export const noticeDelete = (data: string) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}
// 发布
export const noticePublish = (data: string) => {
  return request({
    url: Api.publish,
    method: 'post',
    data,
  })
}
